@**
 * Renders a linkage rule as a tree.
 * jQuery.treeview.js and linkageRuleTree.css must be in the header.
 *@
@(rule: org.silkframework.rule.LinkageRule)

@import org.silkframework.rule.Operator
@import org.silkframework.rule.similarity.{Comparison, Aggregation}
@import org.silkframework.util.DPair
@import org.silkframework.rule.input.{PathInput, TransformInput}

<ul class="details-tree">
  @for(aggregation <- rule.operator.toList) {
    @renderOperator(aggregation)
  }
</ul>

@**
 * Renders a linkage rule operator.
 *@
@renderOperator(op: Operator) = { @op match {
  case Aggregation(id, required, weight, aggregator, operators) => {
    <li>
      <span class="aggregation">Aggregation: @aggregator.plugin.id</span>
      <ul>
        @operators.map(renderOperator)
      </ul>
    </li>
  }
  case Comparison(id, required, weight, threshold, indexing, metric, DPair(input1, input2)) => {
    <li>
      <span class="comparison">Comparison: @metric.plugin.id (@threshold.toString)</span>
      <ul>
        @renderOperator(input1)
        @renderOperator(input2)
      </ul>
    </li>
  }
  case TransformInput(id, transformer, inputs) => {
    <li>
      <span class="transform">Transformation: @transformer.plugin.id</span>
      <ul>
        @inputs.map(renderOperator)
      </ul>
    </li>
  }
  case PathInput(id, path) => {
    <li>
      <span class="input">Input: @path.serialize</span>
    </li>
  }
}}
